#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
int _QuickSort(int arr[], int left, int right)
{
	int keyi = left, dest = keyi, cur = dest + 1;
	while (cur <= right)
	{
		if (arr[cur] <= arr[keyi] && ++dest != cur)
		{
			swap(arr[dest], arr[cur]);
		}
		++cur;
	}
	swap(arr[dest], arr[keyi]);
	return dest;
}
void QuickSort(int* arr, int left, int right)
{
	if (left >= right) return;
	int keyi = _QuickSort(arr, left, right);
	QuickSort(arr, left, keyi - 1);
	QuickSort(arr, keyi + 1, right);

}
int main()
{
	int arr[] = { 2, 5, 6, 9, 1, 3, 4 };
	int n = sizeof(arr) / sizeof(arr[0]);
	QuickSort(arr, 0, n - 1);
	for (int i = 0; i < n; ++i)
	{
		cout << arr[i] << " ";
	}
	cout << endl;
	return 0;
}